import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

import { createRouterGuards } from '@/router/routerGuards'
import { systemRoutes } from '@/router/routes'

// 路由模式
const routerMode = {
  history: () => createWebHistory(),
  hash: () => createWebHashHistory(),
}

// 创建路由实例
const router = createRouter({
  history: routerMode[import.meta.env.VITE_ROUTER_MODE as "history" | "hash"](),
  routes: systemRoutes,
});

// 设置路由守卫
createRouterGuards(router)

export default router
